<!doctype html> 
<html ng-app='text'> 
<head> 
    <meta charset="utf-8"> 
    <title></title>  
    <script type="text/javascript" src='angular.js'></script>
    <script type="text/javascript">
 
    var app = angular.module('text',[]);


    app.factory('leo',function (){
        return {
            x:20,
            l:{m:30,k:40},
            p:function(n){
                alert(n)
            }
        }
    });


    app.controller('const1',function ($scope,leo){
        leo.p(10)
       // console.log(leo.l.k);

    });

    </script>
</head>
<body ng-controller='const1'>



</body>
</html>